from util_for_argparse import get_cuda_port_args

args = get_cuda_port_args()

import requests

# Flask API 服务器的地址和端口
url = f'http://127.0.0.1:{args.port}/parse'
img_path = '/mnt/nas/shengjie/datasets/reid_sysu30k/sysu_test_set_all/gallery/000028311/000028311_c1_1.jpg'

with open(img_path, 'rb') as f:
    files = {'image': f}
    response = requests.post(url, files=files)

# 检查响应
if response.status_code == 200:
    # 保存返回的解析结果图片
    with open('parse_result.png', 'wb') as out:
        out.write(response.content)
    print("解析结果已保存为 parse_result.png")
else:
    print("请求失败，状态码:", response.status_code)
    print("返回内容:", response.text)
